/* 
    Purpose: Using the output from 1a_Census1960_fathers30to50.do,
    		 this file calculates average income (personal,
    		 family-level, and household-level) at the occupation x
    		 race x south level of variation. Then the ratio of 
    		 total income:income from earnings is calculated
    		 (separately for personal income, family income, 
    		 and household income).

    Note: The 1960 5% Census is big enough that it is not 
    	  necessary to weight averages. Perwt confirms that 
    	  everyone is assigned the same weight.

    Creates: IncomeRatios_1960_farm_self_emp.dta
*/
clear
set more off
cd "$Mydirectory1/1_DataSources/CensusData/"

*------------------------------------------------------------------------------------*
*------------------------------------------------------------------------------------*

	use ./input/Census1960_5pct_fathers30to50_adjustments.dta, clear 
	sum perwt, d 

* Separate people with occupations in 200's based on self-employment
	replace occ1950=occ1950+1000 if (occ1950>=200 & occ1950<300) & classwkr==1
	
* Crosswalk Census occupations to coarsened ANES occupations
	drop if occ1950==997 | occ1950==999 //drop missing or unknown
	merge m:1 occ1950 using ../Crosswalks/Crosswalk_1950Census_toANES.dta
	drop if _merge==2
	
* Keep farmers and self-employed 
	keep if occ1950ej==21 | occ1950ej==81
	
* Collapse income measures (at occupation x race x south level)
	keep if incwage!=0 //Note: Many people have 0s, so ratios will be off if 0s are kept.
	
	local income "incwage inctot fam_earnings ftotinc hh_earnings hh_income "
	collapse (rawsum) number (mean) `income', by(occ1950ej race south_merge)
	
/* Create ratio of total income: income from earnings 
   (at person level, family level, and household level) */
	gen ratio_person = inctot / incwage
	gen ratio_family = ftotinc / fam_earnings
	gen ratio_hh = hh_income / hh_earnings 
	
	label var ratio_person "Ratio of inctot to incwage"
	label var ratio_family  "Ratio of total family income to family earnings"
	label var ratio_hh "Ratio of total HH income to HH earnings"
	rename occ1950ej fatheroccej 
	drop `income'
	
	compress
	save "./output/IncomeRatios_1960_farm_self_emp.dta", replace